#include "weaveendinstructionview.h"
#include "ui_weaveendinstructionview.h"

WeaveEndInstructionView::WeaveEndInstructionView(int styleId,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::WeaveEndInstructionView)
{
    ui->setupUi(this);
    setGeometry(5,50,451,544);
    initialDisplayStyle(styleId);

}

void WeaveEndInstructionView::initialDisplayStyle(int styleId)
{
    switch (styleId) {
    case 1:
        ui->save_Btn->setGeometry(360,350,70,40);
        break;
    default:
        break;
    }
}
void WeaveEndInstructionView::getInput(WeaveEndInstruction &instructionParaOut)
{
    instructionParaOut.comment=ui->note_lineEdit->text();
    instructionParaOut.weaveEndType=E_WEAVEEND_TYPE_COMMON;

}

void WeaveEndInstructionView::updateView()
{

    ui->note_lineEdit->setText(instructionPara.comment);
}

void WeaveEndInstructionView::changeLanguage(int language)
{

}

void WeaveEndInstructionView::finishEditInstruction(WeaveEndInstruction instructionParaIn, QString &instructionStrOut)
{
    instructionStrOut.clear();
       instructionStrOut="Weave End";
       switch (instructionParaIn.weaveEndType) {
       case E_WEAVEEND_TYPE_COMMON:

           break;
       case E_WEAVEEND_TYPE_PROPERTY:

           instructionStrOut+=" ["
                          +QString::number(instructionParaIn.weavePropertyIndex)+"]";
           break;
       default:
           break;
       }
      instructionStrOut+=";//"+instructionParaIn.comment;
}

void WeaveEndInstructionView::on_button_editCondition_clicked()
{

}

void WeaveEndInstructionView::on_clearNote_Btn_clicked()
{
    ui->note_lineEdit->setText("");

}

void WeaveEndInstructionView::on_save_Btn_clicked()
{
    getInput(instructionPara);
    finishEditInstruction(instructionPara,instructionStr);
//    emit finishEditInstructionSignal();

    emit saveInstructionSignal(instructionStr);
}


WeaveEndInstructionView::~WeaveEndInstructionView()
{
    delete ui;
}
